﻿using Atha.Contracts;
using IronRuby;

namespace Atha.Languages.IronRuby
{
	public sealed class RubyTestRunContext : ScriptTestRunContextBase
	{
		public RubyTestRunContext(string name, string script)
			: base(name, script)
		{
		}

		protected override void OnExecute(string script, ITestRunResultBuilder testRunResultBuilder)
		{
			var rb = Ruby.CreateEngine();
			var rbScope = rb.CreateScope();

			var executionCtx = new CamelCaseTestExecutionContext(testRunResultBuilder);

			rbScope.SetVariable("atha", executionCtx);

			rb.Execute(script, rbScope);
		}
	}
}